import pytest
import requests
from requests_toolbelt.multipart.encoder import MultipartEncoder
from common import yaml_util
import json

class Test_Flag:
    @pytest.mark.parametrize('caseinfo',yaml_util.Yaml_Util().read_testcase_yaml('hyshop.yml'))
    def test_createflag(self,caseinfo):
        token = 'bf7d765aef2f43ce9334663872f04bac91f501f62ec51db092d35b2ef86f12be'
        # data = MultipartEncoder({'data':str({"body":{"orderId":1}})})
        data = MultipartEncoder({'data':str(caseinfo['body'])})
        header = {'Content-Type':data.content_type,'accept':'*/*','Authorization':token,'app':'huayunShop','source':'ylmApp'}
        print(type(data),data,caseinfo['url'])
        res = requests.post(url=caseinfo['url'],headers=header,data=data)
        print(res.json())

if __name__ == '__main__':
    pytest.main(['-vs'])
    # data = caseinfo['body']
    # data = {
    # 'data':{
    # "body": {
    # "invoices":[{
    # "invoiceTitle":"抬头",
    # "invoiceTaxNumber":"税号",
    # "invoiceContent":"内容",
    # "invoiceType":1,
    # "invoiceRiseType":2,
    # "invoiceEmail":"1006170239@qq.com",
    # "invoicePhone":"15292080897",
    # "storeId":123}],
    # "memos":[{
    # "memo":"备注",
    # "storeId":1 }],
    # "ordertype": 1,
    # "addressId":431027,
    # "skuId":120903,
    # "storeAndSelfTakingAddress": [{"selfTakingAddressId":1,
    # "storeId":1}],
    # "type":"ORDER_PRODUCT",
    # "productNum":1}}}